package tw.singleton.SingleObject;

//饿汉式加载
public class HungrySingle {

    //HungrySingle 的一个对象
    private static HungrySingle instance = new HungrySingle();
    //让构造函数为 private，这样该类就不会被实例化
    private HungrySingle(){}
    //获取唯一可用的对象
    public static HungrySingle getInstance(){
        return instance;
    }
    public void showMessage(){
        System.out.println("Hello World!饿汉式加载，多线程安全");
    }
}
